import { ResouceConst } from "../../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { BaseItem } from "../../../common/BaseItem";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { ObjCreate } from "../../../common/ObjCreate";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ItemData } from "../../../../resource/info/ItemData";
import { Cache } from "../../../../cache/Cache";
import { DrugBagRecoveryConfig } from "../../../../resource/DrugBagRecoveryConfig";
import { EDrug } from "../../../../../../Message/Public/EDrug";
import { HTMLUtil } from "../../../../../../com/gengine/utils/HTMLUtil";
import { RuneUtil } from "../RuneUtil";
import { ColorConfig } from "../../../../resource/ColorConfig";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { ScaleBitmap } from "../../../../../../com/mui/display/ScaleBitmap";
import { TRuneEffect } from "../../../../../../Message/Db/Tables/TRuneEffect";
type int = number;
//class RuneGuideInfoItem
    
    export  class RuneGuideInfoItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._itemBg = ResouceConst.getScaleBitmap(ImagesConst.PackItemBg);
            this._itemBg.width = 66;
            this._itemBg.height = 66;
            this._itemBg.x = 0;
            this._itemBg.y = 0;
            addChild(this._itemBg);
            this._item = new BaseItem();
            this._item.setSize(60, 60);
            this._item.x = this._itemBg.x + 3;
            this._item.y = this._itemBg.y + 3;
            addChild(this._item);
            this._titleBg = ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg);
            this._titleBg.width = 80;
            this._titleBg.height = 18;
            this._titleBg.x = -6;
            this._titleBg.y = 70;
            addChild(this._titleBg);
            var loc1=new GTextFormat("", 14, 65280, true);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._itemName = ObjCreate.createTextField("无符文", 0, 20, 60, 30, this, loc1);
            this._itemName.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._itemName.mouseEnabled = false;
            var loc2=new GTextFormat("", 12, 65280);
            loc2.align = flash.text.TextFormatAlign.CENTER;
            this._effectTxt = ObjCreate.createTextField("", 3, this._titleBg.y, 60, 20, this, loc2);
            this._effectTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            return;
        }

        /* internal  */onRuneResLoaded(): void
        {
            if (this._index != 4) 
            {
                this._bmp = GlobalClass.getBitmap(ImagesConst.RuneArrow);
                this._bmp.x = 67;
                this._bmp.y = 22;
                addChild(this._bmp);
            }
            else if (this._bmp && this._bmp.parent) 
            {
                removeChild(this._bmp);
            }
            return;
        }

        public updateData(arg1: int, arg2: int, arg3: int): void
        {
            var loc4=null;
            var loc5=NaN;
            this._sourceItem = new ItemData(arg1);
            var loc1=Cache.instance.role.entityInfo.maxLife;
            var loc2=DrugBagRecoveryConfig.instance.getConfigByLevel(EDrug._EDrugLifeBag, Cache.instance.role.entityInfo.level);
            var loc3=int(loc2 / 1000) + int(loc2 % 1000 / 100 * loc1);
            if (arg2 == 0) 
            {
                this._itemName.visible = true;
                this._item.itemData = this._sourceItem;
                this._effectTxt.htmlText = HTMLUtil.addColor(loc3.toString(), "#ffffff");
            }
            else 
            {
                this._itemName.visible = false;
                this._itemData = new ItemData(arg2);
                this._item.itemData = this._itemData;
                if ((loc4 = RuneUtil.getRuneEffectByItemData(this._itemData)).length > 0) 
                {
                    this._tRune = loc4[0];
                    loc5 = loc3 + RuneUtil.getRuneEffectResult(loc1, this._tRune.effectValue, 0, true, false);
                    this._effectTxt.htmlText = HTMLUtil.addColor(loc5.toString(), ColorConfig.instance.getItemColorString(this._itemData.color));
                }
            }
            this._index = arg3;
            if (arg3 != 4) 
            {
                LoaderHelp.addResCallBack(ResFileConst.rune, this.onRuneResLoaded);
            }
            return;
        }

        public dispose(): void
        {
            if (this._bmp && this._bmp.parent) 
            {
                removeChild(this._bmp);
            }
            return;
        }

        public /* override */ get width(): number
        {
            return 100;
        }

        /* internal */ /* var */_itemBg: ScaleBitmap;

        /* internal */ /* var */_item: BaseItem;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_tRune: TRuneEffect;

        /* internal */ /* var */_sourceItem: ItemData;

        /* internal */ /* var */_effectTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_titleBg: ScaleBitmap;

        /* internal */ /* var */_itemName: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_index: int;
    }
